<%-- 
    Document   : consumption.jsp
    Created on : 30.07.2009, 14:13:55
    Author     : Mario
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="../STYLES/serverStyles.css" />
        <title>FBIS - VERBRAUCH</title>
        <script>
            document.userCon.submit();
        </script>
    </head>
    <body>
        <jsp:useBean id="bookings" scope="application" class="de.stalinski.db.BookingsConnector" />
        <jsp:useBean id="consumers" scope="application" class="de.stalinski.db.ConsumersConnector" />
        <%
        long past = 24 * 60 * 60 * 1000 * 21;
        java.util.Date daysPast = new java.util.Date(System.currentTimeMillis() - past);
        java.util.Date today = new java.util.Date(System.currentTimeMillis());
        java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd");
        String from = "";
        String to = "";
        String cns = "";
        if (request.getParameter("fromDate") != null && !request.getParameter("fromDate").equals("")) {
            from = request.getParameter("fromDate");
        } else {
            from = df.format(daysPast);
        }

        if (request.getParameter("toDate") != null && !request.getParameter("toDate").equals("")) {
            to = request.getParameter("toDate");
        } else {
            to = df.format(today);
        }

        if (request.getParameter("consumer") != null && !request.getParameter("consumer").equals("")) {
            cns = request.getParameter("consumer");
        } else {
            cns = "Alle";
        }



        %>
        <div id="container">
            <div id="header">
                <jsp:include page="../HTML/header.html"/>
            </div>
            <div id="leftBar">
                <form name="frm" action="" method="GET">
                    <div class="leftMenu">
                    <table>
                        <tbody>
                            <tr>
                                <td>Verbrauch</td><td>&nbsp;</td>
                            </tr>
                            <tr>
                                <td>Von:</td><td><input type="text" name="fromDate" value="<%=from%>"/></td>
                            </tr>
                            <tr>
                                <td>Bis:</td><td><input type="text" name="toDate" value="<%=to%>"/></td>
                            </tr>
                           
                            <tr>
                                <td>Für:</td><td><% out.print(consumers.getUserDropDown(true));%></td>
                            </tr>
                            <tr><form name="userCon" action="" method="POST">
                                    <td>&nbsp;</td><td><input type="submit" value="Anzeigen"/></td>
                                </form>
                            </tr>
                            <tr>
                                <td><a class="button" href="../menu.jsp"><span>Zurück</span></a></td>
                            </tr>
                        </tbody>
                    </table>
                    </div>
                </form>
            </div>
            <div id="content">
                <div class="scroll">
                    <%
        String fD = request.getParameter("fromDate");
        String tD = request.getParameter("toDate");
        String consumer = request.getParameter("consumer");
        out.print(bookings.getConsumptionFor(fD, tD, consumer));
                    %>
                </div>
            </div>
          
            <div id="footer" >
                <jsp:include page="../HTML/footer.html"/>
            </div>
        </div>
    </body>
</html>
